SWI EEPROM Click
SWI EEPROM Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Jun 2023.
- Type : GPIO type
Software Support
Example Description
This example demonstrates the use of SWI EEPROM Click board by writing specified data to the memory and reading it back.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.SWIEEPROM
Example Key Functions
- swieeprom_cfg_setup Config Object Initialization function.
void swieeprom_cfg_setup ( swieeprom_cfg_t *cfg );
- swieeprom_init Initialization function.
err_t swieeprom_init(swieeprom_t *ctx)
SWI EEPROM initialization function.
SWI EEPROM Click context object.
Definition swieeprom.h:99
- swieeprom_mem_write_page This function writes data to the specified memory address page.
err_t swieeprom_mem_write_page(swieeprom_t *ctx, uint8_t start_addr, uint8_t *data_in, uint8_t len)
SWI EEPROM memory write page function.
- swieeprom_mem_read This function reads data from the specified memory address.
err_t swieeprom_mem_read(swieeprom_t *ctx, uint8_t start_addr, uint8_t *data_out, uint8_t len)
SWI EEPROM memory read function.
- swieeprom_mem_clear This function clears the whole memory to zero.
err_t swieeprom_mem_clear(swieeprom_t *ctx)
SWI EEPROM memory clear function.
Application Init
Initializes the driver and logger and checks the communication.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
swieeprom.swi_reset = &swieeprom_reset;
swieeprom.swi_start_stop = &swieeprom_start_stop;
swieeprom.swi_logic_0 = &swieeprom_logic_write_0;
swieeprom.swi_logic_1 = &swieeprom_logic_write_1;
swieeprom.swi_logic_read = &swieeprom_logic_read;
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Check communication." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
err_t swieeprom_check_communication(swieeprom_t *ctx)
SWI EEPROM check communication function.
void application_init(void)
Definition main.c:117
@ SWIEEPROM_ERROR
Definition swieeprom.h:117
Application Task
Writes the specified text message to the memory and reads it back. After that, erases the whole memory and tries to read the same message verifying that the memory is erased. All data is being displayed on the USB UART where you can track the program flow.
{
uint8_t data_buf[ 8 ] = { 0 };
log_printf ( &logger,
" Memory address: 0x%.2X\r\n", ( uint16_t )
STARTING_ADDRESS );
{
log_printf ( &logger, " Write data: %s\r\n", data_buf );
Delay_ms ( 100 );
}
memset ( data_buf, 0, sizeof ( data_buf ) );
data_buf, sizeof ( data_buf ) ) )
{
log_printf ( &logger, " Read data: %s\r\n", data_buf );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
{
log_printf ( &logger, " Memory clear\r\n" );
Delay_ms ( 100 );
}
memset ( data_buf, 0, sizeof ( data_buf ) );
data_buf, sizeof ( data_buf ) ) )
{
log_printf ( &logger, " Read data: %s\r\n\n", data_buf );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
}
#define DEMO_TEXT_MESSAGE
Definition main.c:33
void application_task(void)
Definition main.c:155
#define STARTING_ADDRESS
Definition main.c:34
@ SWIEEPROM_OK
Definition swieeprom.h:116
Note
This application is written for the following MCUs and specifically for MIKROBUS 1: STM32F407ZG, MK64FN1M0VDC12, TM4C129XNCZAD, GD32VF103VBT6, PIC32MX795F512L In order to use it on another MCUs the pin_x functions must be defined in a way it matches the required timing specifications for the Single Wire interface.
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.